package com.weirong.smartvault.backservice.entity_model;

import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.CashboxUnitRepository;
import com.weirong.smartvault.dao.ForeignCurrencyTypeRepository;
import com.weirong.smartvault.entity.CashboxRealtime;
import com.weirong.smartvault.entity.CashboxUnit;
import com.weirong.smartvault.entity.ForeignCurrencyType;

/**
 * Created with IntelliJ IDEA.
 * User: kfeb4
 * Date: 2017/12/28
 * Time: 16:08
 */
public class CashboxRealtimeModel {
    CashboxRealtime cashboxRealtime;
    ForeignCurrencyTypeRepository foreignCurrencyTypeRepository;
    CashboxUnitRepository cashboxUnitRepository;
    public CashboxRealtimeModel(CashboxRealtime cashboxRealtime){
        this.cashboxRealtime= cashboxRealtime;
        foreignCurrencyTypeRepository = SpringContextUtil.getBean(ForeignCurrencyTypeRepository.class);
        cashboxUnitRepository = SpringContextUtil.getBean(CashboxUnitRepository.class);

    }
    public Integer getSlotNo() {
        return this.cashboxRealtime.getSlotNo();
    }

    public String getCode() {
        return cashboxRealtime.getCode();

    }

    public Integer getDenominationValue() {
        return cashboxRealtime.getDenominationValue();
    }

    public String getCashName() {
        String code = cashboxRealtime.getTypeCode();
        ForeignCurrencyType foreignCurrencyType = foreignCurrencyTypeRepository.getByCode(code);
        return foreignCurrencyType.getName();
    }

    public String getUnitName() {
        Integer no = cashboxRealtime.getUnitNo();
        CashboxUnit cashboxUnit = cashboxUnitRepository.findCashboxUnitByNo(no);
        return cashboxUnit.getName();
    }

    public String getDescription() {
        return "";
    }
}
